<?php
class album{
	var $id_album;
	var $name;
	var $public;
	var $id_user;
	
	var $mnum;
	var $res;

//	function album(){}
	
	function get_albums($user_id){
		$this->res = mysql_query("SELECT * FROM albums where id_user_fkn = $user_id;");
		$this->mnum = mysql_num_rows($this->res);
	}
	
	function fillinfo(){
			if($obj = mysql_fetch_object($this->res)){
			$this->id_album= $obj->id_album;
			$this->name = $obj->name;
			$this->public = $obj->public;
			$this->id_user = $obj->id_user_fkn;
			return true;
			}else return false;
	}

	function add(){
		mysql_query("INSERT INTO album(name,public,id_user_fkn)
		 VALUES
		  ('$this->name', '$this->public','$this->id_user');");		
		return  mysql_insert_id();
	}
	
	function edit(){
		//echo "UPDATE users SET  guard_password_tx='$this->password', guard_lastname_tx='$this->lastname', guard_firstname_tx='$this->firstname', guard_phone_tx='$this->phone', guard_mail_tx='$this->mail', guard_cotier_stage_n='$this->stagecotier', guard_gender_n='$this->gendre', guard_hauturier_n='$this->hauturier', guard_cotier_n='$this->cotier', guard_carte_verte_n='$this->carte' WHERE guard_id_n=$this->id;";
		return mysql_query("
		UPDATE cursus SET  
		    level='$this->level', etablissement='$this->etablissement', year='$this->year', description='$this->description' 
		WHERE
		    id_cursus = $this->id_cursus");
	}
	
	function drop(){
		echo "DELETE FROM cursus WHERE id_cursus = $this->id_cursus;";
		return  mysql_query("DELETE FROM cursus WHERE id_cursus = $this->id_cursus;");
		}
		
function show_add_form(){
	?>
	<form class="cmxform" id="signupForm" method="POST" action="index.php">
	<fieldset>
		<legend>Albums</legend>
		
		<p>
			<label for="album">Nom d'album</label>
			<input id="album" name="album"/>
		</p>
		<p>
			<label for="public">Public</label>
			<input type="radio" id="public" name="public" value="1">
			<label for="privee">Privee</label>
			<input type="radio" id="private" name="public" value="0">
		</p>
		<p>
			<input class="submit" type="button" value="Submit" name="sbt" onclick="add_album('<?=$this->id_user?>')" />
		</p>
	</fieldset>
</form>	
<div id="album_res" class="div_info"> </div><br>

	<?php
}//----------------------------------------end of show form function 

}
?>

